package com.np.objectboxdemo1.database;

import com.np.objectboxdemo1.bean.UserBean;

import java.util.List;

import io.objectbox.Box;

public class UserDB {

    private static Box<UserBean> box;

    private static Box<UserBean> getBox() {
        if(box == null) {
            box = ObjectBox.get().boxFor(UserBean.class);
        }
        return box;
    }

    public static List<UserBean> list(){
        return getBox().getAll();
    }

    public static void put(UserBean bean){
        getBox().put(bean);
    }

    public static void removeAll(){
        getBox().removeAll();
    }
}
